//============================================================================
// Name        : coins.cpp
// Author      : dnul
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>

using namespace std;
using namespace cv;

vector<vector<Point> > contours;
vector<Vec4i> hierarchy;

/*
int main() {
	Mat image = imread("/home/diego/monedometro/resources/Monedas/captures/byCoin/50-cara-1.jpg");
	Mat img,gray,laplace,thresh,thresh2,sobel;
	cvtColor(image,gray,CV_BGR2GRAY);
	imshow("imagen",image);
	imshow("gray",gray);
	Laplacian(gray,laplace,gray.depth(),3);
	imshow("laplace",laplace);
	threshold(laplace,thresh,30,255,CV_THRESH_BINARY_INV);
	Sobel(image,sobel,gray.depth(),1,1);

//	imwrite("laplace-thresh.jpg",thresh);
//	imshow("thresh",thresh);1
	vector<vector<Point> > contours0;
	findContours( thresh, contours0, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

    Mat cnt_img = Mat::zeros(thresh.rows, thresh.cols, CV_8UC3);

    contours.resize(contours0.size());
    for( size_t k = 0; k < contours0.size(); k++ )
        approxPolyDP(Mat(contours0[k]), contours[k], 0.1, true);

    int _levels = 0;
    drawContours( cnt_img, contours, _levels <= 0 ? 3 : -1, Scalar(128,255,255),
               3, CV_AA, hierarchy, std::abs(_levels) );


    //detect and draw circles
    vector<Vec3f> circles;
	HoughCircles(gray, circles, CV_HOUGH_GRADIENT,
                     2, gray.rows, 200, 1000 );


    for( size_t i = 0; i < circles.size(); i++ )
        {
             Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
             int radius = cvRound(circles[i][2]);
             // draw the circle center
             circle( sobel, center, 3, Scalar(0,255,0), -1, 8, 0 );
             // draw the circle outline
             circle( sobel, center, radius, Scalar(0,0,255), 3, 8, 0 );
        }
    cout << "circles:" << circles.size();
    imshow("Circles",image);
    imshow("sobel",sobel);


    imwrite("laplace.png",laplace);
//    imshow("contours",cnt_img);

	cvWaitKey(0);
}
*/
